home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12256 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.2 KB  |  61 lines

  1. Path: nntp-server.caltech.edu!news
  2. From: Xuhua Li <xuhua@cco.caltech.edu>
  3. Newsgroups: comp.lang.c++
  4. Subject: HELP about Visual C++
  5. Date: Mon, 18 Mar 1996 18:21:40 -0800
  6. Organization: California Institute of Technology, Pasadena
  7. Message-ID: <314E1A34.1935@cco.caltech.edu>
  8. NNTP-Posting-Host: xuhua-ppp.caltech.edu
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=gb2312
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
  13.  
  14. When I try to simulate the EOF from the keyboard in Visual C++ with 
  15. CTRL+Z from the command line, it doesn't work. CTRL+Z just kill 
  16. the running program without flushing the output. I am running windows 
  17. 95. I try many different key combinations, and none works as EOF. What 
  18. is wrong with Visual C++, no way to simulate EOF from command line? 
  19. Somebody said that it may be a bug in VC++. How can I get rid of this
  20. bug?
  21.  
  22. BTW, are there any Visual C++ news groups or mailing lists? Is there 
  23. free on-line C++ support? It seems Microsoft charges a lot for technical 
  24. support. I am just a student learning VC++ and cannot afford their 
  25. technical support subscrition for developers.
  26.  
  27. I am very disappointed with Visual C++, it seems Borland is much much 
  28. better, what do you think?
  29.  
  30. Thank you very much for your help! 
  31. Please try the following simple program from <<C++ Primer Plus>>:
  32.  
  33. Program #1
  34. // textin3.cpp -- reading chars to end of file
  35. #include <iostream.h>
  36. int main(void)
  37. {
  38.         char ch;
  39.         int count = 0;
  40.  
  41.         while (cin.get(ch))      // cin.get(ch) is 0 on EOF
  42.         {
  43.                 cout << ch;
  44.                 count++;
  45.         }
  46.         cout << count << " characters read\n";
  47.         return 0;
  48. }
  49.  
  50. The following is somebody's suggestion:
  51. When I do this with Viaul C++, hitting CTRL-Z does end the program
  52. without flushing the output.  Even adding cout.flush() does not
  53. improve matters.  However, if you add logic to end the loop for
  54. some other reason, such as encountering a 'q' key, it is fine,
  55. which leads me to believe that the DOS emulation in either VC++
  56. or Windows95 is closing cout when the EOF is encountered for cin.
  57.  
  58. When this is compiled and run using Borland 4.5 it works
  59. (i.e., prints the count), so it sounds like a bug in the VC++
  60. cin/cout command-line emulation.
  61.